Skip to content

deps: make the sqlx TLS backend selectable - #967

Open
gz wants to merge 2 commits into
supabase:mainfrom
feldera:sqlx-aws-lc-rs-main
Open

deps: make the sqlx TLS backend selectable#967
gz wants to merge 2 commits into
supabase:mainfrom
feldera:sqlx-aws-lc-rs-main

Conversation

@gz

@gz gz commented Aug 8, 2026

Copy link
Copy Markdown

sqlx's tls-rustls feature is an alias for tls-rustls-ring, so every crate here links ring with no way for a consumer to choose otherwise. sqlx also prefers ring when both backends are enabled, so a consumer cannot override it by adding a feature: the choice has to be made where the dependency is declared.

The library crates now expose tls-rustls-ring and tls-rustls-aws-lc-rs, defaulting to ring so nothing changes for existing users. Binaries keep ring explicitly. This lets a consumer that already uses aws-lc-rs elsewhere avoid linking two cryptographic implementations; etl-postgres is itself such a case, since it declares rustls with the aws-lc-rs feature while its sqlx pulls ring.

What kind of change does this PR introduce?

Build feature

What is the current behavior?

Two crypto implementations being pulled in as opposed to one

What is the new behavior?

Configurable build to use aws-lc-rs everywhere

@gz
gz requested a review from a team as a code owner August 8, 2026 17:52
@farazdagi
farazdagi requested review from farazdagi and removed request for a team August 21, 2026 08:20
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 73.18% (-2.0%) from 75.203% — feldera:sqlx-aws-lc-rs-main into supabase:main

@farazdagi

Copy link
Copy Markdown
Contributor

Yeah, I think the rationale makes sense, but there are a few cases that need to be fixed before this is ready:

  • In etl, make each TLS feature enable the same feature on etl-postgres.
  • In etl-maintenance, replace the hardcoded ring feature with selectable ring/AWS-LC features, and pass the selected feature to etl.
  • In etl-destinations, pass the selected feature to etl and, when DuckLake is enabled, to etl-maintenance.
  • In the workspace binaries and examples, explicitly select ring on the ETL dependencies so they preserve the current behavior.
  • Add an AWS-LC-only CI check with default features disabled. It should also verify that the SQLx ring feature is absent; --all-features enables both and ends up testing ring.

There is also one compatibility question. Today, default-features = false still includes SQLx TLS because the TLS feature is enabled directly on the SQLx dependency. After this PR, the same configuration would build without TLS unless the user explicitly selects a provider.

I think the no-provider configuration should fail at compile time instead of silently building ETL without TLS. For etl, I mean a check along these lines:

#[cfg(not(any(
    feature = "tls-rustls-ring",
    feature = "tls-rustls-aws-lc-rs",
)))]
compile_error!(
    "Either `tls-rustls-ring` or `tls-rustls-aws-lc-rs` must be enabled."
);

Direct etl-postgres users should get the same protection when the SQLx store is enabled:

#[cfg(all(
    feature = "store",
    not(any(
        feature = "tls-rustls-ring",
        feature = "tls-rustls-aws-lc-rs",
    )),
))]
compile_error!(
    "Either `tls-rustls-ring` or `tls-rustls-aws-lc-rs` must be enabled when `store` is enabled."
);

This would be a breaking change for users with default-features = false: their existing build would stop until they select one of the two providers. The failure and the required fix would at least be explicit, rather than changing the TLS behavior silently.

@iambriccardo, wdyt? Is requiring those users to select a TLS provider an acceptable breaking change? If yes, I think the compile-time checks plus documenting the required feature are the safest way to handle it. If not, I don't think this design can both preserve the old behavior and support an AWS-LC-only build.

Copy link
Copy Markdown
Contributor

I think this is a fair change to do. We are currently in alpha phase, so breaking changes are expected.

@farazdagi farazdagi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, please do the changes I asked in the comment, and we will take it from there.

gz added 2 commits September 3, 2026 10:33
sqlx's tls-rustls feature is an alias for tls-rustls-ring, so every crate here links ring with no way for a consumer to choose otherwise. sqlx also prefers ring when both backends are enabled, so a consumer cannot override it by adding a feature: the choice has to be made where the dependency is declared.

The library crates now expose tls-rustls-ring and tls-rustls-aws-lc-rs, defaulting to ring so nothing changes for existing users. Binaries keep ring explicitly. This lets a consumer that already uses aws-lc-rs elsewhere avoid linking two cryptographic implementations; etl-postgres is itself such a case, since it declares rustls with the aws-lc-rs feature while its sqlx pulls ring.

Signed-off-by: Gerd Zellweger <mail@gerdzellweger.com>
… one

Each library crate now forwards its tls-rustls-ring or tls-rustls-aws-lc-rs feature to the ETL crates it depends on, so selecting a backend on etl-destinations or etl-maintenance also selects it on etl and etl-postgres. etl-maintenance replaces its hardcoded ring feature with the same selectable pair.

etl and etl-postgres fail at compile time when neither backend is enabled, so a default-features = false build cannot silently drop TLS. The etl-postgres check is unconditional because sqlx is a required dependency used by the source, slots, lag, and store modules.

Binaries, examples, and the fuzz crate select ring explicitly to preserve current behavior. A new CI job builds the library crates with only AWS-LC and verifies that the sqlx ring feature is absent from the resolved feature graph.

Signed-off-by: Gerd Zellweger <mail@gerdzellweger.com>
@gz
gz force-pushed the sqlx-aws-lc-rs-main branch from d0b28af to dc5ffdf Compare September 3, 2026 17:38
@gz

gz commented Sep 3, 2026

Copy link
Copy Markdown
Author

@farazdagi sorry for the delay, please have another look at the PR which now should include your changes requested

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants